package com.sam.im.heiqun.uis.widgets;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;

import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

public class MyPlayer extends StandardGSYVideoPlayer {

    public onLongTouchListener mLongTouche;

    public MyPlayer(@NonNull Context context) {
        super(context);
    }

    public MyPlayer(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }


    public MyPlayer(Context context, Boolean fullFlag) {
        super(context, fullFlag);
    }


    boolean isFirst=true;

    @Override
    protected void init(Context context) {
        super.init(context);
        post(new Runnable() {
            @Override
            public void run() {
                gestureDetector = new GestureDetector(getContext().getApplicationContext(), new GestureDetector.SimpleOnGestureListener() {
                    @Override
                    public boolean onDoubleTap(MotionEvent e) {
                        touchDoubleUp();
                        return super.onDoubleTap(e);
                    }

                    @Override
                    public boolean onSingleTapConfirmed(MotionEvent e) {
                        if (!mChangePosition && !mChangeVolume && !mBrightness) {
                            onClickUiToggle();
                        }
                       // Debuger.printfError("555a","9999999999999999999999");
                        Log.d("huangrui","长按11" );
                        return super.onSingleTapConfirmed(e);
                    }



                    @Override
                    public void onLongPress(MotionEvent e) {
                        super.onLongPress(e);
                     /*   if(isFirst){
                            isFirst=false;
                        }else{*/
                            Log.d("huangrui","长按222" );
                            mLongTouche.onLongTouch();
                       // }

                       // Debuger.printfError("555a","0000000000000000000000");
                    }
                });
            }
        });
    }


    public void setmLongTouche(onLongTouchListener mLongTouche) {
        this.mLongTouche = mLongTouche;
    }

    public interface onLongTouchListener{
        void onLongTouch();
    }

}